<template>
    <view>
        <!--标题和返回-->
		<cu-custom :bgColor="NavBarColor" isBack :backRouterName="backRouteName">
			<block slot="backText">返回</block>
			<block slot="content">斜坡单元风险评价因子权重及赋值</block>
		</cu-custom>
		 <!--表单区域-->
		<view>
			<form>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">切坡墙距权重：</text></view>
                  <input type="number" placeholder="请输入切坡墙距权重" v-model="model.slopeWallDistanceWeight"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">切坡墙距 A＜1：</text></view>
                  <input type="number" placeholder="请输入切坡墙距 A＜1" v-model="model.slopeWallDistance1"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">切坡墙距 1≤A＜2：</text></view>
                  <input type="number" placeholder="请输入切坡墙距 1≤A＜2" v-model="model.slopeWallDistance2"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">切坡墙距 2≤A＜4：</text></view>
                  <input type="number" placeholder="请输入切坡墙距 2≤A＜4" v-model="model.slopeWallDistance3"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">切坡墙距 4≤A：</text></view>
                  <input type="number" placeholder="请输入切坡墙距 4≤A" v-model="model.slopeWallDistance4"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">切坡时间权重：</text></view>
                  <input type="number" placeholder="请输入切坡时间权重" v-model="model.cutSlopeTimeWeight"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">切坡时间 2013年以前：</text></view>
                  <input type="number" placeholder="请输入切坡时间 2013年以前" v-model="model.cutSlopeTime1"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">切坡时间 2013年以后：</text></view>
                  <input type="number" placeholder="请输入切坡时间 2013年以后" v-model="model.cutSlopeTime2"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">切坡宽度权重：</text></view>
                  <input type="number" placeholder="请输入切坡宽度权重" v-model="model.cutSlopeWidthWeight"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">切坡宽度 B≤25m：</text></view>
                  <input type="number" placeholder="请输入切坡宽度 B≤25m" v-model="model.cutSlopeWidth1"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">切坡宽度 25m＜B≤50m：</text></view>
                  <input type="number" placeholder="请输入切坡宽度 25m＜B≤50m" v-model="model.cutSlopeWidth2"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">切坡宽度 50m＜B≤100m：</text></view>
                  <input type="number" placeholder="请输入切坡宽度 50m＜B≤100m" v-model="model.cutSlopeWidth3"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">切坡宽度 B＞100m：</text></view>
                  <input type="number" placeholder="请输入切坡宽度 B＞100m" v-model="model.cutSlopeWidth4"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">威胁人口权重：</text></view>
                  <input type="number" placeholder="请输入威胁人口权重" v-model="model.threatPopulationWeight"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">威胁人口 C＜3：</text></view>
                  <input type="number" placeholder="请输入威胁人口 C＜3" v-model="model.threatPopulation1"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">威胁人口 3≤C＜10：</text></view>
                  <input type="number" placeholder="请输入威胁人口 3≤C＜10" v-model="model.threatPopulation2"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">威胁人口 10≤C＜30：</text></view>
                  <input type="number" placeholder="请输入威胁人口 10≤C＜30" v-model="model.threatPopulation3"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">威胁人口 30≤C：</text></view>
                  <input type="number" placeholder="请输入威胁人口 30≤C" v-model="model.threatPopulation4"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">威胁房屋结构权重：</text></view>
                  <input type="number" placeholder="请输入威胁房屋结构权重" v-model="model.threatHouseWeight"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">威胁房屋结构 钢混及钢结构：</text></view>
                  <input type="number" placeholder="请输入威胁房屋结构 钢混及钢结构" v-model="model.threatHouse1"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">威胁房屋结构 砖混：</text></view>
                  <input type="number" placeholder="请输入威胁房屋结构 砖混" v-model="model.threatHouse2"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">威胁房屋结构 砖木：</text></view>
                  <input type="number" placeholder="请输入威胁房屋结构 砖木" v-model="model.threatHouse3"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">威胁房屋结构 土木及土坯：</text></view>
                  <input type="number" placeholder="请输入威胁房屋结构 土木及土坯" v-model="model.threatHouse4"/>
                </view>
              </view>
				<view class="padding">
					<button class="cu-btn block bg-blue margin-tb-sm lg" @click="onSubmit">
						<text v-if="loading" class="cuIcon-loading2 cuIconfont-spin"></text>提交
					</button>
				</view>
			</form>
		</view>
    </view>
</template>

<script>
    import myDate from '@/components/my-componets/my-date.vue'

    export default {
        name: "SlopeRiskEvaluationSettingForm",
        components:{ myDate },
        props:{
          formData:{
              type:Object,
              default:()=>{},
              required:false
          }
        },
        data(){
            return {
				CustomBar: this.CustomBar,
				NavBarColor: this.NavBarColor,
				loading:false,
                model: {},
                backRouteName:'index',
                url: {
                  queryById: "/sloperiskevaluationsetting/slopeRiskEvaluationSetting/queryById",
                  add: "/sloperiskevaluationsetting/slopeRiskEvaluationSetting/add",
                  edit: "/sloperiskevaluationsetting/slopeRiskEvaluationSetting/edit",
                },
            }
        },
        created(){
             this.initFormData();
        },
        methods:{
           initFormData(){
               if(this.formData){
                    let dataId = this.formData.dataId;
                    this.$http.get(this.url.queryById,{params:{id:dataId}}).then((res)=>{
                        if(res.data.success){
                            console.log("表单数据",res);
                            this.model = res.data.result;
                        }
                    })
                }
            },
            onSubmit() {
                let myForm = {...this.model};
                this.loading = true;
                let url = myForm.id?this.url.edit:this.url.add;
				this.$http.post(url,myForm).then(res=>{
				   console.log("res",res)
				   this.loading = false
				   this.$Router.push({name:this.backRouteName})
				}).catch(()=>{
					this.loading = false
				});
            }
        }
    }
</script>
